<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="query">
				<el-form-item>
					<el-input v-model="query.keyword" placeholder="姓名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getPermissions">查询</el-button>
				</el-form-item>

			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" style="width: 100%;">


			<el-table-column prop="name" label="权限名" width="150" sortable>
			</el-table-column>
			<el-table-column prop="sn" label="标识" width="300"  sortable>
			</el-table-column>
			<el-table-column prop="url" label="资源路径" width="200" sortable>
			</el-table-column>
			<el-table-column prop="parent.name" label="父权限" width="120" sortable>
			</el-table-column>

		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">

			<el-pagination layout="prev, pager, next"
                     @current-change="handleCurrentChange"
                     :page-size="this.query.pageSize" :total="pageInfo.total"
                     style="float:right;">
			</el-pagination>
		</el-col>


	</section>
</template>

<script>


	export default {
		data() {
			return {
				listLoading: false,
				pageInfo:{
				  total:0,
          rows:[]
        },
        query:{
				  pageSize: 10,
          currentPage:1,
          keyword:''
        }
			}
		},
		methods: {

			handleCurrentChange(val) {
				this.page = val;
				this.getPermissions();
			},
			//获取用户列表
			getPermissions() {

				this.listLoading = true;
				this.$http.put("/permission",this.query)
        .then(result =>{
          result = result.data
          if (result.success){
            this.$message({message: '查询成功',type: 'success' });
            this.listLoading = false;
            console.log(result.objData);
            this.pageInfo = result.objData
          }else{
            this.$message({message: '请联系管理员!',type: 'warning' });
          }
        })
        .catch(result =>{
          this.$message({message: '请联系管理员!',type: 'warning' });
        })

			},
		},
		mounted() {
			this.getPermissions();
		}
	}

</script>

<style scoped>

</style>